namespace ui {

	export function getStage(): egret.Stage {
		return egret.MainContext.instance.stage;
	}

	export function getStageWidth(): number {
		return egret.MainContext.instance.stage.stageWidth;
	}

	export function getStageHeight(): number {
		return egret.MainContext.instance.stage.stageHeight;
	}

	export function getDeviceRatio(): number {
		return getStageWidth() / getStageHeight();
	}

	export function addToStage<T extends egret.DisplayObject>(obj: T): T {
		if (!obj) return;
		getStage().addChild(obj);
		return obj;
	}

	export function lockScreen(): void {
		getStage().touchChildren = false;
	}

	export function unlockScreen(): void {
		getStage().touchChildren = true;
	}

	export function setMaxTouches(num: number): void {
		getStage().maxTouches = num;
	}

	export function setFrameRate(rate: number): void {
		getStage().frameRate = rate;
	}

	export function getScaleMode(): string {
		return getStage().scaleMode;
	}

	export function getOrientationMode(): string {
		return getStage().orientation;
	}
}